{php}
use think\Request;
$arr_img = !empty($one['images']) ? explode(',',$one['images']) : explode(',',$one_basic['images']); //图片组
$arr1 = !empty($one['content']) ? json_decode($one['content'],true) : json_decode($one_basic['content'],true);$arr12 = json_decode($one_basic['content'],true); //基本资料 which 是1或2，代表使用了one还是one_basic
//合并arr1 和 arr12
foreach($arr1 as $i => $son){
    $arr12[$i] = $son;
}
$arr2 = !empty($one['place_record']) ? json_decode($one['place_record'],true) : json_decode($one_basic['place_record'],true); //产地
$arr3 = !empty($one['farming_record']) ? json_decode($one['farming_record'],true) : json_decode($one_basic['farming_record'],true); //日常管理
$arr4 = !empty($one['production_record']) ? json_decode($one['production_record'],true) : json_decode($one_basic['production_record'],true); //生产记录
$arr5 = !empty($one['fertilizer_record']) ? json_decode($one['fertilizer_record'],true) : json_decode($one_basic['fertilizer_record'],true); //施肥记录
$arr6 = !empty($one['pesticides_record']) ? json_decode($one['pesticides_record'],true) : json_decode($one_basic['pesticides_record'],true); //喷药记录
$arr7 = !empty($one['testing_record']) ? json_decode($one['testing_record'],true) : json_decode($one_basic['testing_record'],true); //质检记录
{/php}
<!DOCTYPE html>
<html>
<head lang="zh-cn">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>农产品追溯平台</title>
  <meta name="renderer" content="webkit">
  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <link rel="alternate icon" type="image/png" href="i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="AMUI React">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <link rel="stylesheet" type="text/css" href="__CDN__/static/aui/css/aui.css" />
  <link rel="stylesheet" type="text/css" href="__CDN__/static/lucnUI/lucn.css" />
  <script language="javascript" src="__CDN__/static/jQuery/jquery-2.1.4.min.js"></script>
<style>
:root {
  --color81: #a2ca43;
  --color1: #339900;
  --color2: #fc8725;
}
body{max-width:640px;min-width: 240px; margin:0 auto; background:#eee; font-size:.7rem; padding-bottom:2.25rem;}
.block{ background:#fff; overflow:hidden;}
.block h3{ color:var( --color1 ); margin-bottom:.3rem;}
.block .list{ line-height:2;}
.h2{ font-size:.8rem; font-weight:100;}
.text-arg{ color:#aaa}
#weather .ssd{ color:var( --color2 ); font-size:2rem;}
#weather .text p{font-size:.7rem; vertical-align:bottom;}
.list .icon{ width:100%; height:auto;}
.layui-m-layercont{ text-align:left!important; font-size.7rem!important; line-height:1.9!important; padding:1.2rem .7rem!important;}
footer{-webkit-box-shadow: 0px 2px 2px #000;box-shadow: 0 -1px 2px #ccc;}
footer a{ color:#212121;}
footer a i{ color:var( --color1 );}
.layui-m-layer1 .layui-m-layerchild{width:100%;height: 100%;overflow-y: scroll;}
.layui-m-layerchild{ display:block;}
</style> 
</head>
<body>
  <article>
  <!--轮播开始-->
  <section class="block slider">
  <link rel="stylesheet" type="text/css" href="__CDN__/static/swiper/swiper-3.3.1.min.css" />
<div class="swiper-container swiper-container-horizontal swiper-container-autoheight">
    <div class="swiper-wrapper">
	  {volist name="arr_img" id="v"}
      <div class="swiper-slide">
	    <a href="#"><img src="{$v}" /></a>
	  </div>
	  {/volist}
	</div>
    <!-- 如果需要分页器 -->
    <div class="swiper-pagination"></div>
</div>
<script type="text/javascript" src="__CDN__/static/swiper/swiper-3.3.1.jquery.min.js"></script>
<script>
$(document).ready(function(){
var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true
    });
});
</script>
<h2 class="aui-content-padded h2">{$one.product_name}</h2>
  </section>
<!--轮播结束-->
<!--扫码信息开始-->
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<div class="aui-row list">
<div class="aui-col-xs-4">
<span class="text-arg">当前追溯码</span>
</div>
<div class="aui-col-xs-8">
{php}echo Request::instance()->param('bar');{/php}
</div>
<div class="aui-col-xs-4">
<span class="text-arg">当前查询位置</span>
</div>
<div class="aui-col-xs-8 myLocation">
<img src="__CDN__/assets/img/loading2.gif">
</div>
</div>
</div>
</section>
<!--扫码信息结束-->

<!--产品详情开始-->
<a name="chanpin"></a>
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 产品详情</h3>
{if condition="count($arr12) gt 0"}
{foreach $arr12 as $key => $vo}
<div class="aui-row list">
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8">
{$vo}
</div>
</div>
{/foreach}
{/if}
</div>
</section>
<!--产品详情结束-->

<!--产地信息开始-->
<a name="chandi"></a>
<section class="block aui-margin-t-10" name="#a2">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 产地信息</h3>
{if condition="count($arr2) gt 0"}
{foreach $arr2 as $key => $vo}
<div class="aui-row list">
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8">
{$vo}
</div>
</div>
{/foreach}
{/if}
<h3>天气信息</h3>
<div id="weather"></div>
<script>
 $.ajax({  
        url:"http://api.map.baidu.com/telematics/v3/weather?location=淮阳&output=json&ak=GH7vVF7dZrlev6OpEqRYL2fU",  
        dataType:"jsonp",  
        jsonpCallback:"admin_cross",  
        success:function(data){  
            //console.log(data)  
		    
			if(data.status == "success"){
			    var html = '<h4>'+data.results[0].currentCity+'</h4><div class="aui-row"><div class="aui-col-xs-6 ssd">'+data.results[0].weather_data[0].temperature+'</div><div class="aui-col-xs-6 text"><p>'+data.results[0].weather_data[0].weather+'</p><p>'+data.results[0].weather_data[0].wind+'</p><p>'+data.results[0].weather_data[0].date+'</p></div></div>';
			    $('#weather').html(html);
		    }
			
        }
		});
</script>
</div>
</section>
<!--产地信息结束-->

<!--生产记录开始-->
<a name="richang"></a>
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 生产记录</h3>
<div class="aui-row list">
{if condition="count($arr4) gt 0"}
{foreach $arr4 as $key => $vo}
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8 modal" data-value="日期@{$key}|{$vo}">
{php}
if(strpos($vo, '|') == true){
$arr_one = explode('|',$vo);
$arr_one2 = explode('@',$arr_one[0]);
echo $arr_one2[1].' <div class="aui-label aui-label-success">查看</div>';
}else{
echo $vo;
}
{/php}
</div>
{/foreach}
{/if}
</div>
</div>
</section>
<!--生产记录结束-->

<!--日常管理开始-->
<a name="richang"></a>
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 日常管理</h3>
<div class="aui-row list">
{if condition="count($arr3) gt 0"}
{foreach $arr3 as $key => $vo}
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8">
{$vo}
</div>
{/foreach}
{/if}
</div>
</div>
</section>
<!--日常管理结束-->

<!--施肥记录开始-->
<a name="shifei"></a>
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 施肥记录</h3>
<div class="aui-row list">
{if condition="count($arr5) gt 0"}
{foreach $arr5 as $key => $vo}
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8 modal" data-value="日期@{$key}|{$vo}">
{php}
if(strpos($vo, '|') == true){
$arr_one = explode('|',$vo);
$arr_one2 = explode('@',$arr_one[0]);
echo $arr_one2[1].' <div class="aui-label aui-label-success">查看</div>';
}else{
echo $vo;
}
{/php}
</div>
{/foreach}
{/if}
</div>
</div>
</section>
<!--施肥记录结束-->

<!--喷药记录开始-->
<!--
<a name="penyao"></a>
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 喷药记录</h3>
<div class="aui-row list">
{if condition="count($arr6) gt 0"}
{foreach $arr6 as $key => $vo}
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8 modal" data-value="日期@{$key}|{$vo}">
{php}
if(strpos($vo, '|') == true){
$arr_one = explode('|',$vo);
$arr_one2 = explode('@',$arr_one[0]);
echo $arr_one2[1].' <div class="aui-label aui-label-success">查看</div>';
}else{
echo $vo;
}
{/php}
</div>
{/foreach}
{/if}
</div>
</div>
</section>
-->
<!--喷药记录结束-->

<!--质检记录开始-->
<a name="zhijian"></a>
<section class="block aui-margin-t-10">
<div class="aui-content-padded">
<h3><i class="aui-iconfont aui-icon-info"></i> 检验报告</h3>
<div class="aui-row list">
{if condition="count($arr7) gt 0"}
{foreach $arr7 as $key => $vo}
<div class="aui-col-xs-4">
<span class="text-arg">{$key}</span>
</div>
<div class="aui-col-xs-8 modal" data-value="日期@{$key}|{$vo}">
{php}
if(strpos($vo, '|') == true){
$arr_one = explode('|',$vo);
$arr_one2 = explode('@',$arr_one[0]);
echo $arr_one2[1].' <div class="aui-label aui-label-success">查看</div>';
}else{
echo $vo;
}
{/php}
</div>
{/foreach}
{/if}
</div>
</div>
</section>
<!--质检记录结束-->
  </article>
  <br><br><br>
  <footer class="aui-bar aui-bar-tab" id="footer">
    <div class="aui-bar-tab-item aui-active" tapmode>
	<a href="#chanpin">
        <i class="aui-iconfont aui-icon-cart"></i>
        <div class="aui-bar-tab-label">产品</div>
    </a>
	</div>
    <div class="aui-bar-tab-item" tapmode>
	<a href="#chandi">
        <i class="aui-iconfont aui-icon-map"></i>
        <div class="aui-bar-tab-label">产地</div>
	</a>
    </div>
    <div class="aui-bar-tab-item" tapmode>
	<a href="#richang">
        <i class="aui-iconfont aui-icon-gear"></i>
        <div class="aui-bar-tab-label">生产</div>
	</a>
    </div>
    <div class="aui-bar-tab-item" tapmode>
	<a href="#zhijian">
        <i class="aui-iconfont aui-icon-info"></i>
        <div class="aui-bar-tab-label">质检</div>
	</a>
    </div>
	<div class="aui-bar-tab-item" tapmode>
	<a href="#shipin" class="modal" data-value="视频@/uploads/video/jg.mp4">
	    <i class="aui-iconfont aui-icon-video"></i>
        <div class="aui-bar-tab-label">企业视频</div>
	</a>
    </div>
</footer>
  <!--<script language="javascript" src="__STATIC__/flexible/flexible.js"></script>-->
  <script language="javascript" src="__CDN__/static/lucnUI/lucn.js"></script>
  <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
  <script>
$('body').on('click','.modal',function(){
var value = $(this).attr('data-value');
var arr = value.split('|');
var html='';
$.each(arr, function(p1, p2){
var arr2 = this.split('@');
if(arr2[0] == '图片'){
html += '<div class="aui-row list"><div class="aui-col-xs-12"><span class="text-arg">'+arr2[0]+'</span></div><div class="aui-col-xs-12"><img src="'+arr2[1]+'"></div></div>';
}else if(arr2[0] == '视频'){
html += '<div class="aui-row list"><div class="aui-col-xs-12"><span class="text-arg">'+arr2[0]+'</span></div><div class="aui-col-xs-12"><video width="100%" controls><source src="'+arr2[1]+'" type="video/mp4"></video><img src=""></div></div>';
}else{
html += '<div class="aui-row list"><div class="aui-col-xs-5"><span class="text-arg">'+arr2[0]+'</span></div><div class="aui-col-xs-5">'+arr2[1]+'</div></div>';
}
});

var pageii = layer.open({
	type: 1
	,content: html
    ,anim: 'up'
	,content: html
	,btn: '关闭'
  });
});

var position_option = {
                enableHighAccuracy: true,
                maximumAge: 30000,
                timeout: 20000
            };
navigator.geolocation.getCurrentPosition(getPositionSuccess, getPositionError, position_option);

//用户定位成功

function getPositionSuccess(position){
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var address;

//通过baiduMap API获取街道名称
var map = new BMap.Map("allmap");
var point = new BMap.Point(lng,lat);
var gc = new BMap.Geocoder();
gc.getLocation(point, function(rs){
  //var addComp = rs.addressComponents;
  //address = addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber;
  address = rs.address;
  //alert("address="+address);
  $('.myLocation').html(rs.address);
							$.post("{:url($module.'/'.$controller_sign.'/visitor')}",
							{
							ip:"{php}echo $_SERVER["REMOTE_ADDR"];{/php}",
							bar:"{php}echo Request::instance()->param('bar');{/php}",
							address:rs.address
							});
});
//alert("longitude="+lng+"  latitude="+lat);

}


//用户定位失败
function getPositionError(error){
switch(error.code){
case error.TIMEOUT:
//alert("连接超时，请重试");
$('.myLocation').html('连接超时');
break;
case error.PERMISSION_DENIED:
//alert("您拒绝了使用位置共享服务，查询已取消");
$('.myLocation').html('获取位置被拒绝');
break;
case error.POSITION_UNAVAILABLE:
//alert("亲爱的火星网友，非常抱歉，我们暂时无法为您所在的星球提供位置服务");
$('.myLocation').html('无法获取您的位置');
break;
}
}

/* 
    //手动定位  
        function user_position(){  
            if (navigator.geolocation){  
                navigator.geolocation.getCurrentPosition(function (position) {  
                    var gg_lon = position.coords.longitude;  
                    var gg_lat =  position.coords.latitude;   
                    var gc = new BMap.Geocoder();   
                    var pointAdd = new BMap.Point(gg_lon, gg_lat);  
                    gc.getLocation(pointAdd, function(rs){  
                            // 百度地图解析城市名  
                            //var city = rs.addressComponents.city;  
                            //或者任何你想要的其他信息
							//alert(rs.address);
							//console.log(rs);
							$('.myLocation').html(rs.address);
							$.post("{:url($module.'/'.$controller_sign.'/visitor')}",
							{
							ip:"{php}echo $_SERVER["REMOTE_ADDR"];{/php}",
							bar:"{php}echo Request::instance()->param('bar');{/php}",
							address:rs.address
							});
                       }  
                    );  
                });    
            }else{  
               $('.myLocation').html('获取位置失败');
            }  
        }  
	user_position();
	*/
    </script> 
	<div class="aaa"></div>
</body>
</html>